package cwinsor.com.leaf_raking;

import java.util.Arrays;
import java.util.List;

public final class Shift {

	private Shift(String n) { name = n; } // private constructor

	private String name;

	public static final Shift AM = new Shift("AM");
	public static final Shift PM = new Shift("PM");

	public static final List<Shift> SHIFTS = Arrays.asList(
			AM,
			PM);

	public final String name() { return name; };

	/*
	 * debug
	 */
	private static String dM = "Shift ----";
	private static String dF = "Shift ---- ERROR ---- ";

	/*
	 * stringToShift
	 * converts string to Shift
	 */
	public static final Shift stringToShift(String theString) {
		if (Integer.valueOf(theString).equals(AM.name())) { return AM; }
		if (Integer.valueOf(theString).equals(PM.name())) { return PM; }
		// default
		System.out.println(dF + "in stringToTeam - cannot convert "
				+ theString 
				+ " to a Shift");
		System.exit(1);
		return null;
	}


	/*
	 * returns a Shift (AM/PM) given a StartTime
	 */
	public static final Shift startTimeToShift(StartTime startTime) {
		if (startTime.equals(StartTime.T_8_30)) { return AM; }
		if (startTime.equals(StartTime.T_10_00)) { return AM; }
		if (startTime.equals(StartTime.T_11_30)) { return AM; }
		if (startTime.equals(StartTime.T_1_00)) { return PM; }
		if (startTime.equals(StartTime.T_2_30)) { return PM; }
		if (startTime.equals(StartTime.T_4_00)) { return PM; }
		// default
		System.out.println(dF + "in startTimeToShift - hit the default");
		System.exit(1);
		return null;
	}

}
